import http from "@/utils/request";
import type { Course, CourseForm, CourseQueryParams } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export const getCoursePage = (queryParams: CourseQueryParams) => {
  return http({
    url: "/api/v1/course/page",
    method: "get",
    params: queryParams,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 获取表单详情
 *
 * @param id
 */
export const getCourseForm = (id: number) =>{
  return http({
    url: "/api/v1/course/getCourseForm",
    method: "get",
    params: {id: id},
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 添加
 *
 * @param data
 */
export const addCourse = (data: Course) => {
  return http({
    url: "/api/v1/course/add",
    method: "post",
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 修改信息
 *
 * @param data
 */
export const updateCourse = (data: CourseForm) => {
  return http({
    url: "/api/v1/course/update",
    method: "put",
    data: data,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

/**
 * 删除信息
 * @param id
 */
export const deleteCourse = (id: number) => {
  return http({
    url: "/api/v1/course/delete",
    method: "delete",
    data: id,
    headers: {
      'Content-Type': 'application/json'
    }
  });
}
